package com.jackyzgy.test.others;

/**
 * 常用分页办法
 * @author Administrator
 *
 */
public class FenYe {
	public static void main(String[] args) {
		int total = 4;
		int size = 5;
		int now = 2;
		
		System.out.println(fenye(now,size,total));
	}
	
	private static int fenye(int now,int size,int total){
		int page = 1;
		
		if(total <= size){
			return page;
		}
		
		if(now > 3 && now < total-1){
			page = now-2;
		}else{
			if(now >= total-1){
				page = total-size+1;
			}
		}
		
		return page;
	}
}
